
export default {
    name: "Index",
    data() {
        return {
            ids: [],
            searchForm: {
                taskName: ''
            },
            tableData: [],
            pager: {
                page: 0,
                size: 20,
                total: 0
            },
            dialogTitle: '流程实例',
            entityId: '',
            fullscreen: true,
            designerVisible: false,
            designerUrl: '',
            workflowInstanceId: '',
        }
    },
    computed: {
        height() {
            return `calc(100vh - 350px)`;
        }
    },
    mounted() {
        this.getList();
        this.workflowInstanceId = this.$route.query.id;
    },
    methods: {

        // 获取任务列表
        getList: function () {
            let params = {
                page: this.pager.page === 0 ? this.pager.page : this.pager.page - 1,
                size: this.pager.size,
                workflowInstanceId: this.$route.query.id,
            };
            this.$api.post(  '/wf/taskWorkitem/progress', params).then(res => {
                if (res.status === '0') {
                    this.tableData = res.data.resContent;
                    this.pager.total = res.data.total;
                }
            });
        },

        dateFormatter: function (row, column) {
            let datetime = row[column.property];
            if (datetime) {
                datetime = new Date(datetime);
                let y = datetime.getFullYear() + '-';
                let mon = datetime.getMonth() + 1 + '-';
                let d = datetime.getDate();
                return y + mon + d;
            }
            return ''
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.pager.size = val;
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.pager.page = val;
        },
        progress: function () {
            let curWwwPath = window.location.href;
            let pos = curWwwPath.indexOf("#" + this.$route.path);
            let localhostPath = curWwwPath.substring(0, pos);
            this.designerUrl =
              localhostPath +
              "static/gui/instance.html?id=" +
              this.workflowInstanceId +
              "&baseURL=" +
              encodeURIComponent( this.baseURL)+"&token="+encodeURIComponent(sessionStorage.getItem("token")||'');
            this.designerVisible = true;
            
        },
        handleDesignerClose: function () {
            this.designerVisible = false;
        },

    }
}
